<template>
    <div class="cgs-app-form-design">
        <a-layout>
            <a-layout-header>
                <div class="cgs-app-logo-container">
                    <span class="el-icon-menu formLogo"></span>
                </div>
                <div class="cgs-app-title-container">
                    <span>表单编辑</span>
                </div>
                <div class="cgs-title-container">
                    <span v-for="item in typeList" :key="item.id" @click="selectVisualType(item)" class="cgs-form-design-type" :class="selectedVisualType===item.id?'selectedVisualType':''">{{item.name}}</span>
                </div>
            </a-layout-header>
            <a-layout-content style="overflow: auto">
                <router-view @formChanged="formChanged" ref="childRoute"/>
            </a-layout-content>
        </a-layout>
    </div>
</template>

<script>
export default {
    data(){
        return{
            typeList:[
                {id: 'fieldEdit', name: '字段编辑', pathIdent: '/formDesign/fieldEdit', disabled: false},
                {id: 'formSet', name: '表单设置', pathIdent: '/formDesign/formSet', disabled: false}
            ],
            selectedVisualType: 'fieldEdit',
            loading: null,
            setUpAble: false
            
        }
    },
    created(){
       this.selectedVisualType = this.$route.name 
    },
    computed: {
        logo: {
            get(){
                return this.$store.state.sysInfo.logo
            },
            set(){}
        },
        appId:{
            get(){
                return this.$route.params.appId
            },
            set(){}
        },
        groupId:{
            get(){
                return this.$route.params.groupId
            },
            set(){}
        },
        worksheetId:{
            get(){
                return this.$route.params.worksheetId
            },
            set(){}
        }
    },
    methods:{
        selectVisualType(typeConfig){
            this.selectedVisualType = typeConfig.id
            this.$router.push({path: `${typeConfig.pathIdent}/${this.appId}/${this.groupId}/${this.worksheetId}`})
        },
        formChanged(){
            console.log(123)
            // this.$refs.childRoute.saveFormData()
        }
    }
}
</script>

<style scoped>
.cgs-app-form-design{
    width: 100%;
    height: 100%;
}

.cgs-app-logo-container .formLogo{
  font-size: 40px;
  color: #409eff;

}
.cgs-app-form-design .cgs-app-logo-container{
    /* width: 100px; */
    height: 60px;
    line-height: 60px;
    text-align: left;
    display: inline-block;
    position: absolute;
    top: 0;
    left: 20px;
    font-size: 25px;
    font-weight: 900;
    padding-top: 5px;
}
.cgs-app-form-design .cgs-app-title-container{
    /* width: 100px; */
    height: 60px;
    line-height: 60px;
    text-align: left;
    display: inline-block;
    position: absolute;
    top: 0;
    left: 65px;
    font-size: 25px;
    font-weight: 900
}
.cgs-app-form-design .cgs-form-design-logo{
    height: 40px;
    margin-right: 10px;
}
.cgs-app-form-design .cgs-title-container{
    text-align: center;
    font-size: 30px;
    font-weight: 900;
}    
.cgs-app-form-design .cgs-content{
    box-sizing: content-box;
    width: 1300px;
    padding: 20px 56px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    /* justify-content: space-between; */
}
.cgs-form-design-type{
    margin: 0px 25px;
    font-size: 20px;
    font-weight: 400;
    color: rgba(43,52,65,.6);
    cursor: pointer;

}
.cgs-form-design-type:hover:not(.selectedVisualType){
    color: #2b3441
}
.cgs-form-design-type.selectedVisualType{
    font-weight: 500;
    color: #2b3441;
    position: relative;

}
.cgs-form-design-type.selectedVisualType:after{
    position: absolute;
    bottom: -17px;
    left: 50%;
    width: 36px;
    height: 5px;
    border-radius: 2px;
    content: "";
    background: #fb9337;
    transform: translateX(-50%);

}

</style>
<style>
.cgs-app-form-design .ant-layout{
    width: 100%;
    height: 100%;    
    background: #fff;
}
.cgs-app-form-design .ant-layout-header{
    background: unset;
    height: 60px;
    line-height: 60px;
    padding: 0 6px 0 24px;
    box-shadow: 0 4px 5px 0 rgb(12 31 80 / 8%);
}

</style>